#pragma once
#include "BasicFunction.h"

class CNMFClass
{
public:
	//Constructor
	CNMFClass(double** m_S, int m_C, int m_R, int m_NumberF, long MaxIte);

	//Initialize
	void NMFInitialize(void);

	//Factorizing
	void NMFFactorizing(void);

	//Get basics
	double** NMFGetBasic(int* m_C, int* m_R);

	//Get encoding
	double** NMFGetComponent(int* m_C, int* m_R);

	//Destroy the NMF
	void NMFDestroy(void);

	//Calculate the cost
	double NMFCalculateCost(void);

	virtual ~CNMFClass(void);

	//Rescale the matrix to 0~1;
	void NMFScale(void);

private:

	//Indicator
	bool m_IsCreated;

	//Original data
	double** m_Original;

	//Basic of the NMF
	double** m_Basic;

	//Encoding of the NMF
	double** m_Component;

	//Number of factors
	int m_NumberFactor;
	
	//The approximation
	double** m_Approximation;

	//Iterations of update
	long m_Iteration;

	//Maximum iteration to update
	long m_MaxIteration;

	//Current cost
	double m_CurrentCost;

	//Previous cost
	double m_PreviousCost;

	//Basicfucntion
	CBasicFunction bf;

	//Size of the matrix
	int m_Column;
	int m_Row;

	//Scale vector
	double m_Min;
	double m_Max;
};
